<?php
    $menu_1 = '';
    $menu_2 = '';
    $menu_3 = '';
    $menu_4 = '';
    $menu_5 = '';
    $menu_6 = '';
    $menu_7 = ' class="active"';
    $menu_8 = '';
    include('header.php');
    
    if(isset($_POST['name'])){
	
	if($_POST['name']==''){
	    alert('Please enter your name.');
	}else{
	    if($_POST['email']==''){
		alert('Please enter your e-mail.');
	    }else{
		if($_POST['comment']==''){
		    alert('Please enter your comment.');
		}else{
		    $html_mail =  '<strong>Name - Surname : </strong>'.$_POST['name'];
		    $html_mail .=  '<br /><strong>E-mail : </strong>'.$_POST['email'];
		    $html_mail .=  '<br /><strong>Subject : </strong>'.$_POST['subject'];
		    $html_mail .=  '<br /><strong>Comment : </strong><br />'.$_POST['comment'];
		    
		    $to      = CONTACT_EMAIL;
		    
		    $subject = 'Message from contact form';
		    $message = $html_mail;
	    
		    $headers  = 'MIME-Version: 1.0' . "\r\n";
		    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
		    $headers .= "From: $email" . "\r\n" .
			    "Reply-To: $email" . "\r\n" .
			    'X-Mailer: PHP/' . phpversion();
	    
		    $result = @mail($to, $subject, $message, $headers);
		    
		    if($result){
			alert('Email has been successfuly send.');
		    }else{
			alert('Can\'t send email, please try agarin later.,');
		    }
		}
	    }
	}
    }
    
    $msg = array();
    $sql = "SELECT td_th FROM text_data WHERE td_id=6 OR td_id=7  OR td_id=8  OR td_id=9 OR td_id=15 ORDER BY td_id";
    $result = $db->Execute($sql);
    $i = 0;
    while (!$result->EOF)
    {
        $msg[$i]['th'] = $result->fields['td_th'];
        $i++;
        $result->MoveNext();
    }
    $result->Close();
?>
	    <div id="main_content">
		
		<div class="page_title" id="history_title">
		    <img src="images/contact_title.jpg" alt="Contact Us" />
		</div>
		
		<div id="content_top">&nbsp;</div>
		<div id="content_center" class="contact_content">
		    
		    <div id="contact_info">
			<p id="contact_info_company_name"><?php echo $msg[0]['th']; ?></p>
			<div class="contact_info_">
			    <label>Address :</label>
			    <?php echo $msg[1]['th']; ?>
			</div>
			<div class="contact_info_">
			    <label>Factory Tel :</label>
			    <?php echo $msg[2]['th']; ?>
			</div>
			<div class="contact_info_">
			    <label>Fax :</label>
			    <?php echo $msg[3]['th']; ?>
			</div>
			<div class="contact_info_">
			    <label>E-mail :</label>
			    <a href="mailto:<?php echo $msg[4]['th']; ?>"><?php echo $msg[4]['th']; ?></a>
			</div>
		    </div>
		    
		    <div id="contact_form">
			<div id="contact_form_title">Sent Comment / Inquiries</div>
			<form method="post">
			<div class="contact_info_ contact_info_from">
			    <label>Name - Surname :</label>
			    <input type="text" class="contact_form" name="name" /> *
			</div>
			<div class="contact_info_ contact_info_from">
			    <label>E-mail :</label>
			    <input type="text" class="contact_form" name="email" /> *
			</div>
			<div class="contact_info_ contact_info_from">
			    <label>Subject :</label>
			    <select class="contact_form" name="subject">
				<option value="Commet">Commet</option>
				<option value="Ingniries">Inquiries</option>
				<option value="Request for more info">Request for more info</option>
			    </select> *
			</div>
			<div class="contact_info_ contact_info_from">
			    <label>Comment :</label>
			    <textarea class="contact_form contact_form_textarea" name="comment"></textarea> *
			</div>
			
			<div class="contact_info_ contact_info_from contact_info_from_remark">
			    <label>&nbsp;</label>
			    (please complete the blank where marked star *)
			</div>
			
			
			<div class="contact_info_ contact_info_from">
			    <label>&nbsp;</label>
			    <input type="submit" class="contact_info_from_bt" value="Send" />
			    <input type="reset" class="contact_info_from_bt" value="Clear" />
			</div>
			</form>
		    </div>
		    
		</div>
		<div id="content_bottom">&nbsp;</div>
		
	    </div>
<?php
    include('footer.php');
?>